<?php
	ob_start();
	session_start(); // on relaye la session
	
	require_once('inc_config.php');

	if(!function_exists('title'))
	{
	function title()
	{
		$exp=explode("/",$_SERVER['REQUEST_URI']);
		$taille = sizeof($exp);
		$last = ucfirst( $exp[$taille-1] );
		$last = explode(".php",$last);
		return $last[0].' :: MicroAssur';
	}
	}
	
	if(!function_exists('strToNoAccent'))
	{
	function strToNoAccent($var)
	{
			$var = str_replace(
			 array(
			  "à", "â", "ä", "á", "ã", "å",
			  "î", "ï", "ì", "í",
			  "ô", "ö", "ò", "ó", "õ", "ø",
			  "ù", "û", "ü", "ú",
			  "é", "è", "ê", "ë",
			  "ç", "ÿ", "ñ","'",
			  "‘","'",
			 ),
			 array(
			  '&agrave;', '&#194;', '	&#196;', '&#193;', '&#195;', '&#197;',
			  '	&#206;', '&#207;', '&#204;', '&#205;',
			  '&#212;', '&#214;', '&#210;', '&#211;', '&#213;', '&#216;',
			  '&#217;', '&#219;', '&#220;', '&#218;',
			  '&eacute;', '&egrave;', '&#234;', '&#235;',
			  '&#199;', '&#255;', '&#241;','&#8217;',
			  '&#8217;','&#8217;',
			 ),$var);
			 
		return $var;
	}
	}
	
	if(!function_exists('colorer'))
	{
   	function colorer ($val,$val2)
	{
		$cls = '<div class='.$val2.'>'.strToNoAccent($val).'</div>';
		return $cls;
	}
	}
	
	
	
	if(isset($_SESSION["is_registered"]) && $_SESSION["is_registered"] == "registered")
	{
		$enregistrer = $_SESSION["is_registered"];
			
		$titleGen = title();
		$message = "";
	}
	else
	{
		header("Location:index.php?erreur=intru"); // redirection en cas d'echec
	}
	
	$_SESSION['num_contrat']= NULL;
	unset ($_SESSION['num_contrat']);
	
	$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
	if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != ""))
	{
	  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
	}
	
	if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true"))
	{
  		session_unset();
  		$logoutGoTo = "index.php";
  		if ($logoutGoTo) 
  		{
    		header("Location: $logoutGoTo");
    		exit;
  		}
	}
	
	$sEditFormAction = $_SERVER['PHP_SELF'];
	if (isset($_SERVER['QUERY_STRING'])) 
	{
  		$sEditFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
	}
	
	if (isset($_GET['idbloc'])) 
		$_SESSION['idbloc'] = $_GET['idbloc'];
		
	if (isset($_GET['idfonction'])) 
		$_SESSION['idfonction'] = $_GET['idfonction'];
		
	$oBloc = new dataObject_menu($_SESSION['idbloc']);
	$oFonction = new dataObject_menu($_SESSION['idfonction']);
	
	global $oBloc;
	global $oFonction;
	global $gsMenu;
	
	$oForm = new valid_formulaire();
	$gbFormValid = $oForm->valider($_POST);
	
	/**/
?>